_package("caf.ui");

_import("alz.core.Animation");
_import("alz.mui.Component");
_import("caf.ui.TabButton");

/**
 * 滚动条组件
 */
_class("TabBar", Component, function(){
	this._init = function(arr, btnNum){
		_super._init.call(this);
		this._animation = null;
		this._conf = null;
		this._btns = {};
		this._btnArr = arr || [];
		this._btnNum = btnNum;
	};
	this.create = function(parent){
		var obj = this.createElement(parent, "div", "caf-tabbar");
		this.setParent(parent);
		this.init(obj);
		return obj;
	};
	this.bind = function(obj, conf){
		this._conf =conf;
		console.log(this._conf);
		this.setParent(conf.parent);
		if(conf.id){
			this.setId(conf.id);
		};
		this.init(obj);
	};
	this.init = function(obj){
		_super.init.apply(this, arguments);
		//this._self.innerHTML = "<span class='title'>" + this._conf.title + "</span>";
		this.creatTabButtons();
	};
	this.dispose = function(){
		_super.dispose.apply(this);
	};
	this.creatTabButtons = function(){
		//console.log(.length)
		for(var i = 0, len = this._btnNum; i < len; i++){
			var btn = new TabButton("tab" + i, this._btnArr[i], "left", i);
			this._btns[i] = btn;
			btn.create(this._self);
			var width = 315 / this._btnNum;
			btn._self.style.width = width + "px";
		}
	};
});